home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F29019_ToolList.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  4.2 KB  |  173 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 1999                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10. // ToolList.cpp : implementation file
  11. //
  12.  
  13. #include "stdafx.h"
  14. #include "InsSmObj.h"
  15. #include "ToolList.h"
  16. #include "SdiDialog.h"
  17.  
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CToolList
  26.  
  27. CToolList::CToolList()
  28. {
  29. }
  30.  
  31. CToolList::~CToolList()
  32. {
  33. }
  34.  
  35.  
  36. BEGIN_MESSAGE_MAP(CToolList, CListBox)
  37.     //{{AFX_MSG_MAP(CToolList)
  38.     ON_WM_MOUSEMOVE()
  39.     ON_WM_LBUTTONUP()
  40.     ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
  41.     ON_WM_LBUTTONDOWN()
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CToolList message handlers
  47.  
  48. void CToolList::OnMouseMove(UINT nFlags, CPoint point) 
  49. {
  50.     // TODO: Add your message handler code here and/or call default
  51.     if(nFlags & MK_LBUTTON)
  52.     {
  53.         
  54.         int dx = m_LB_DOWNpoint.x - point.x;
  55.         int dy = m_LB_DOWNpoint.y - point.y;
  56.         CPoint Pt = point;
  57.  
  58.         if((abs(dx) > 1 || abs(dy) > 1) && m_drag)
  59.         {
  60. // if dragging
  61.             if (((CSdiDialog*)GetParent())->m_dwEventConnection == 0)
  62.             {
  63.                 ((CSdiDialog*)GetParent())->ConnectEvents();
  64.             }
  65.                 m_OldCursor = GetCursor();
  66.                 m_NewCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1));
  67.                 SetCursor(m_NewCursor);
  68.                 ShowCursor(TRUE);
  69.                 m_drag = FALSE;
  70.                 m_LB_DOWNpoint.x = -1;
  71.                 m_LB_DOWNpoint.y = -1;
  72.                 ((CSdiDialog*)GetParent())->m_FirstClick = TRUE;
  73.                 return;
  74.             
  75.         }
  76.  
  77.         ClientToScreen(&Pt);
  78.         CWnd *pClickWNd = WindowFromPoint(Pt);
  79.  
  80.         if(pClickWNd && pClickWNd != this)
  81.         {
  82.             pClickWNd->ScreenToClient(&Pt);
  83.             pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y));
  84.         }
  85.  
  86.     }
  87.  }
  88.  
  89.  
  90.  
  91. void CToolList::OnLButtonUp(UINT nFlags, CPoint point) 
  92. {
  93.     CListBox::OnLButtonUp(nFlags, point);
  94.     m_drag = FALSE;
  95.  
  96.     CPoint Pt = point;
  97.     ClientToScreen(&Pt);
  98.     CWnd *pClickWNd = WindowFromPoint(Pt);
  99.         
  100.     if(pClickWNd && pClickWNd != this)
  101.     {
  102.         pClickWNd->ScreenToClient(&Pt);
  103.         pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y));
  104.         SetCursor(m_OldCursor);
  105.         ShowCursor(TRUE);
  106.         return;
  107.                             
  108.     }
  109.     else
  110.     {
  111.         SetCursor(m_OldCursor);
  112.         ShowCursor(TRUE);
  113.  
  114.     }
  115. }
  116.  
  117.  
  118. void CToolList::OnSelchange() 
  119.  
  120. {
  121.     // TODO: Add your control notification handler code here
  122.  
  123.     
  124.     CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_LIST1));
  125.  
  126.     HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT));
  127.     
  128.     int index = pList->GetCurSel();
  129.     CString cstrSelected;
  130.  
  131.     pList->GetText(index, cstrSelected);
  132.     if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
  133.     {
  134.         CViewWnd *m_wndView = (CViewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
  135.         m_wndView->Clear();
  136.     
  137.         m_wndView->DoPreview();
  138.         m_cstrCurSelected = cstrSelected;
  139.         m_wndView->Invalidate();
  140.     }
  141.     ::SetCursor(hOC);
  142.  
  143. }
  144.  
  145. void CToolList::OnLButtonDown(UINT nFlags, CPoint point) 
  146. {
  147.     // TODO: Add your message handler code here and/or call default
  148.     
  149.     BOOL ret;
  150.  
  151.     CListBox::OnLButtonDown(nFlags, point);
  152.     m_drag = TRUE; 
  153.     m_LB_DOWNpoint.x = point.x;
  154.     m_LB_DOWNpoint.y = point.y;
  155.  
  156.     CString cstrSelected;
  157.  
  158.     GetText(ItemFromPoint(point, ret), cstrSelected);
  159.     
  160.     if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
  161.     {
  162.         BeginWaitCursor();    
  163.         CViewWnd *m_wndView = (CViewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
  164.         m_wndView->Clear();
  165.     
  166.         m_wndView->DoPreview();
  167.         m_cstrCurSelected = cstrSelected;
  168.         m_wndView->Invalidate();
  169.         EndWaitCursor();
  170.     }
  171.  
  172. }
  173.